﻿using Firefly.Framework.Windows.ContentReaders;
using Firefly.Framework.Windows.Forms;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;

namespace Firefly.ContentPipeline.Windows.Forms
{
    [ContentTypeWriter]
    public class MoveableComponentContentWriter : ContentTypeWriter<MoveableControl>
    {
        protected override void Write(ContentWriter output, MoveableControl value)
        {
            WriteMoveableComponent(output, value);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(MoveableControlContentReader).AssemblyQualifiedName;
        }

        internal static void WriteMoveableComponent(ContentWriter output, MoveableControl value)
        {
            ControlContentWriter.WriteComponent(output, value);
            output.Write(value.Sizeable);
            output.Write(value.HandleSize);
            output.Write(value.Draggable);
            output.WriteObject<Rectangle>(value.DragHandle);
            output.Write((int)value.DragHandleDock);
            output.WriteObject<Point>(value.MinimumSize);
        }
    }
}
